Skip to content

📝 Update 05-patch-prediction notebook for the New API#977

Merged
shaneahmed merged 21 commits intodev-define-engines-abcfrom
dev-update-example-notebooks
Jan 9, 2026
Merged

📝 Update 05-patch-prediction notebook for the New API#977
shaneahmed merged 21 commits intodev-define-engines-abcfrom
dev-update-example-notebooks

Conversation

@gozdeg
Copy link
Collaborator

@gozdeg gozdeg commented Dec 15, 2025

Summary

This PR updates the patch‑prediction example to align with the new PatchPredictor engine and fixes a long‑standing issue in EngineABC related to model‑attribute retrieval when using DataParallel.


What’s Changed

🔧 Example Notebook Updates

  • Updated examples/05-patch-prediction.ipynb to use the new PatchPredictor engine API.
  • Added a new “Visualize in TIAViz” section, allowing readers to directly inspect prediction results inside TIAViz for a smoother, more interactive workflow.

🐛 EngineABC Bug Fix

  • Fixed a bug in EngineABC where model attributes were incorrectly retrieved from a DataParallel wrapper.
  • Introduced _get_model_attr() to safely unwrap the underlying model when needed.
  • This resolves multi‑GPU crashes caused by attributes living on the wrapped module instead of the actual model.

Why This Matters

  • Ensures the patch‑prediction example stays up‑to‑date with the latest engine design.
  • Improves multi‑GPU stability and prevents confusing attribute‑access errors.
  • Enhances the user experience by integrating TIAViz visualization directly into the example workflow.

Testing

  • Verified that the updated notebook runs end‑to‑end with the new engine.
  • Confirmed that multi‑GPU training and inference no longer crash when accessing model attributes.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@codecov
Copy link

codecov bot commented Dec 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.30%. Comparing base (d40dc64) to head (e600960).

Additional details and impacted files
@@                   Coverage Diff                   @@
##           dev-define-engines-abc     #977   +/-   ##
=======================================================
  Coverage                   95.30%   95.30%           
=======================================================
  Files                          79       79           
  Lines                        9945     9955   +10     
  Branches                     1280     1280           
=======================================================
+ Hits                         9478     9488   +10     
  Misses                        431      431           
  Partials                       36       36           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@shaneahmed shaneahmed changed the title 📝 Make changes to 05-patch-prediction notebook 📝 Update 05-patch-prediction notebook to Make it Compatible with the New Engines API Dec 17, 2025
@shaneahmed shaneahmed changed the title 📝 Update 05-patch-prediction notebook to Make it Compatible with the New Engines API 📝 Update 05-patch-prediction notebook for the New API Dec 17, 2025
@gozdeg gozdeg marked this pull request as ready for review December 18, 2025 17:59
@shaneahmed shaneahmed added this to the Release v2.0.0 milestone Dec 19, 2025
@shaneahmed shaneahmed added the documentation Improvements or additions to documentation label Dec 19, 2025
"""
for path in files:
notebook = json.loads(path.read_text())
with Path.open(path, encoding="utf-8", errors="ignore") as f:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
with Path.open(path, encoding="utf-8", errors="ignore") as f:
notebook = json.loads(path.read_text())

for path in files:
notebook = json.loads(path.read_text())
with Path.open(path, encoding="utf-8", errors="ignore") as f:
notebook = json.load(f)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
notebook = json.load(f)

@review-notebook-app
Copy link

review-notebook-app bot commented Dec 19, 2025

View / edit / reply to this conversation on ReviewNB

shaneahmed commented on 2025-12-19T11:40:55Z
----------------------------------------------------------------

zarr_output = zarr.open("path/to/zarr", mode="r")

predictions = {}

for key in zarr_output:

predictions[key]=da.from_zarr(zarr_output[key})

_ = predictor.save_predictions(predictions, output_type="annotation_store")


@review-notebook-app
Copy link

review-notebook-app bot commented Dec 19, 2025

View / edit / reply to this conversation on ReviewNB

shaneahmed commented on 2025-12-19T11:40:55Z
----------------------------------------------------------------

Line #2.    tiatoolbox visualize --slides ./tmp/slides --overlays ./tmp/wsi_predictions_annotationstore/

@review-notebook-app
Copy link

review-notebook-app bot commented Dec 19, 2025

View / edit / reply to this conversation on ReviewNB

shaneahmed commented on 2025-12-19T11:45:19Z
----------------------------------------------------------------

Add class_dict for visualization


@shaneahmed shaneahmed merged commit 9f8c041 into dev-define-engines-abc Jan 9, 2026
3 checks passed
@shaneahmed shaneahmed deleted the dev-update-example-notebooks branch January 9, 2026 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants